package com.mmp.main.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.mmp.common.util.SearchRequired;

/**
 * The persistent class for the hospital_device database table.
 *
 */
@Entity
@Table(name = "hospital_device")
@NamedQuery(name = "HospitalDevice.findAll", query = "SELECT h FROM HospitalDevice h ORDER BY h.deviceName")
public class HospitalDevice implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	private Integer id;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "add_date")
	private Date addDate;

	@Column(name = "added_from_another_location")
	private Boolean addedFromAnotherLocation;

	@Column(name = "agent_name")
	private String agentName;

	@SearchRequired
	private String code;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_in")
	private Date createdIn;

	@Column(name = "device_name")
	private String deviceName;

	@Column(name = "location_name")
	private String locationName;

	@Column(name = "manufacturer_name")
	private String manufacturerName;

	private String model;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "operation_date")
	private Date operationDate;

	@Column(name = "pm_annual_visits_no")
	private Integer pmAnnualVisitsNo;

	@Column(name = "pm_visits_months")
	private String pmVisitsMonths;

	private Float price;

	@Column(name = "serial_no")
	@SearchRequired
	private String serialNo;

	private Integer status;

	@Column(name = "ta3mid_no")
	private String ta3midNo;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "warranty_expire_date")
	private Date warrantyExpireDate;

	@Column(name = "within_contract")
	@SearchRequired
	private Boolean withinContract;

	@Column(name = "within_warranty")
	@SearchRequired
	private Boolean withinWarranty;

	// bi-directional many-to-one association to Hospital
	@ManyToOne
	@JoinColumn(name = "hosp_id")
	private Hospital hospital;

	// bi-directional many-to-one association to HospitalDepatment
	@ManyToOne
	@JoinColumn(name = "department_id")
	@SearchRequired(isObject = true)
	private HospitalDepatment hospitalDepatment;

	// bi-directional many-to-one association to LookupDeviceCategory
	@ManyToOne
	@JoinColumn(name = "category_id")
	@SearchRequired(isObject = true)
	private LookupDeviceCategory lookupDeviceCategory;

	// bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name = "created_by")
	private User user;

	// bi-directional many-to-one association to HospitalDeviceAccessory
	@LazyCollection(LazyCollectionOption.FALSE)
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "hospitalDevice", orphanRemoval = true)
	private List<HospitalDeviceAccessory> hospitalDeviceAccessories;

	// bi-directional many-to-one association to HospitalDevicePpmDetail
	@OneToMany(mappedBy = "hospitalDevice")
	private List<HospitalDevicePpmDetail> hospitalDevicePpmDetails;

	// bi-directional many-to-one association to HospitalDeviceScrappingInfo
	// @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL,mappedBy="hospitalDevice")
	@OneToOne(mappedBy = "hospitalDevice")
	// private List<HospitalDeviceScrappingInfo> hospitalDeviceScrappingInfos;
	private HospitalDeviceScrappingInfo hospitalDeviceScrappingInfo;

	// bi-directional many-to-one association to JobOrder
	@OneToMany(mappedBy = "hospitalDevice")
	@Fetch(value = FetchMode.SUBSELECT)
	private List<JobOrder> jobOrders;

	private String subcontractor;

	public HospitalDevice() {
	}

	public void setSubcontractor(String subcontractor) {
		this.subcontractor = subcontractor;
	}

	public String getSubcontractor() {
		return subcontractor;
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getAddDate() {
		return this.addDate;
	}

	public void setAddDate(Date addDate) {
		this.addDate = addDate;
	}

	public Boolean getAddedFromAnotherLocation() {
		return this.addedFromAnotherLocation;
	}

	public void setAddedFromAnotherLocation(Boolean addedFromAnotherLocation) {
		this.addedFromAnotherLocation = addedFromAnotherLocation;
	}

	public String getAgentName() {
		return this.agentName;
	}

	public void setAgentName(String agentName) {
		this.agentName = agentName;
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Date getCreatedIn() {
		return this.createdIn;
	}

	public void setCreatedIn(Date createdIn) {
		this.createdIn = createdIn;
	}

	public String getDeviceName() {
		return this.deviceName;
	}

	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}

	public String getLocationName() {
		return this.locationName;
	}

	public void setLocationName(String locationName) {
		this.locationName = locationName;
	}

	public String getManufacturerName() {
		return this.manufacturerName;
	}

	public void setManufacturerName(String manufacturerName) {
		this.manufacturerName = manufacturerName;
	}

	public String getModel() {
		return this.model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public Date getOperationDate() {
		return this.operationDate;
	}

	public void setOperationDate(Date operationDate) {
		this.operationDate = operationDate;
	}

	public Integer getPmAnnualVisitsNo() {
		return this.pmAnnualVisitsNo;
	}

	public void setPmAnnualVisitsNo(Integer pmAnnualVisitsNo) {
		this.pmAnnualVisitsNo = pmAnnualVisitsNo;
	}

	public String getPmVisitsMonths() {
		return this.pmVisitsMonths;
	}

	public void setPmVisitsMonths(String pmVisitsMonths) {
		this.pmVisitsMonths = pmVisitsMonths;
	}

	public Float getPrice() {
		return this.price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	public String getSerialNo() {
		return this.serialNo;
	}

	public void setSerialNo(String serialNo) {
		this.serialNo = serialNo;
	}

	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getTa3midNo() {
		return this.ta3midNo;
	}

	public void setTa3midNo(String ta3midNo) {
		this.ta3midNo = ta3midNo;
	}

	public Date getWarrantyExpireDate() {
		return this.warrantyExpireDate;
	}

	public void setWarrantyExpireDate(Date warrantyExpireDate) {
		this.warrantyExpireDate = warrantyExpireDate;
	}

	public Boolean getWithinContract() {
		return this.withinContract;
	}

	public void setWithinContract(Boolean withinContract) {
		this.withinContract = withinContract;
	}

	public Boolean getWithinWarranty() {
		return this.withinWarranty;
	}

	public void setWithinWarranty(Boolean withinWarranty) {
		this.withinWarranty = withinWarranty;
	}

	public Hospital getHospital() {
		return this.hospital;
	}

	public void setHospital(Hospital hospital) {
		this.hospital = hospital;
	}

	public HospitalDepatment getHospitalDepatment() {
		return this.hospitalDepatment;
	}

	public void setHospitalDepatment(HospitalDepatment hospitalDepatment) {
		this.hospitalDepatment = hospitalDepatment;
	}

	public LookupDeviceCategory getLookupDeviceCategory() {
		return this.lookupDeviceCategory;
	}

	public void setLookupDeviceCategory(LookupDeviceCategory lookupDeviceCategory) {
		this.lookupDeviceCategory = lookupDeviceCategory;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<HospitalDeviceAccessory> getHospitalDeviceAccessories() {
		return this.hospitalDeviceAccessories;
	}

	public void setHospitalDeviceAccessories(List<HospitalDeviceAccessory> hospitalDeviceAccessories) {
		this.hospitalDeviceAccessories = hospitalDeviceAccessories;
	}

	public HospitalDeviceAccessory addHospitalDeviceAccessory(HospitalDeviceAccessory hospitalDeviceAccessory) {
		getHospitalDeviceAccessories().add(hospitalDeviceAccessory);
		hospitalDeviceAccessory.setHospitalDevice(this);

		return hospitalDeviceAccessory;
	}

	public HospitalDeviceAccessory removeHospitalDeviceAccessory(HospitalDeviceAccessory hospitalDeviceAccessory) {
		getHospitalDeviceAccessories().remove(hospitalDeviceAccessory);
		hospitalDeviceAccessory.setHospitalDevice(null);

		return hospitalDeviceAccessory;
	}

	public List<HospitalDevicePpmDetail> getHospitalDevicePpmDetails() {
		return this.hospitalDevicePpmDetails;
	}

	public void setHospitalDevicePpmDetails(List<HospitalDevicePpmDetail> hospitalDevicePpmDetails) {
		this.hospitalDevicePpmDetails = hospitalDevicePpmDetails;
	}

	public HospitalDevicePpmDetail addHospitalDevicePpmDetail(HospitalDevicePpmDetail hospitalDevicePpmDetail) {
		getHospitalDevicePpmDetails().add(hospitalDevicePpmDetail);
		hospitalDevicePpmDetail.setHospitalDevice(this);

		return hospitalDevicePpmDetail;
	}

	public HospitalDevicePpmDetail removeHospitalDevicePpmDetail(HospitalDevicePpmDetail hospitalDevicePpmDetail) {
		getHospitalDevicePpmDetails().remove(hospitalDevicePpmDetail);
		hospitalDevicePpmDetail.setHospitalDevice(null);

		return hospitalDevicePpmDetail;
	}

	public HospitalDeviceScrappingInfo getHospitalDeviceScrappingInfo() {
		return this.hospitalDeviceScrappingInfo;
	}

	public void setHospitalDeviceScrappingInfo(HospitalDeviceScrappingInfo hospitalDeviceScrappingInfo) {
		this.hospitalDeviceScrappingInfo = hospitalDeviceScrappingInfo;
	}

	// public HospitalDeviceScrappingInfo
	// addHospitalDeviceScrappingInfo(HospitalDeviceScrappingInfo
	// hospitalDeviceScrappingInfo) {
	// getHospitalDeviceScrappingInfos().add(hospitalDeviceScrappingInfo);
	// hospitalDeviceScrappingInfo.setHospitalDevice(this);
	//
	// return hospitalDeviceScrappingInfo;
	// }

	// public HospitalDeviceScrappingInfo
	// removeHospitalDeviceScrappingInfo(HospitalDeviceScrappingInfo
	// hospitalDeviceScrappingInfo) {
	// getHospitalDeviceScrappingInfos().remove(hospitalDeviceScrappingInfo);
	// hospitalDeviceScrappingInfo.setHospitalDevice(null);
	//
	// return hospitalDeviceScrappingInfo;
	// }

	public List<JobOrder> getJobOrders() {
		return this.jobOrders;
	}

	public void setJobOrders(List<JobOrder> jobOrders) {
		this.jobOrders = jobOrders;
	}

	public JobOrder addJobOrder(JobOrder jobOrder) {
		getJobOrders().add(jobOrder);
		jobOrder.setHospitalDevice(this);

		return jobOrder;
	}

	public JobOrder removeJobOrder(JobOrder jobOrder) {
		getJobOrders().remove(jobOrder);
		jobOrder.setHospitalDevice(null);

		return jobOrder;
	}

}
